package com.yanqu.road.server.cmd.activity.cat;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.CatProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.cat.CatModule;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.cat.CatMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = GameProtocol.S_CAT_ABILITY_UPGRADE, desc = "攻击力升级")
public class CatRoleAbilityUpgradeCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        // 没有活动
        if (!ActivityMgr.activityInShowTime(CatMgr.getActivityInfo()) || CatMgr.getConfig() == null) {
            ret = GameErrorCode.E_ACTIVITY_OVER_TIME;
            return;
        }

        ret = player.getModule(CatModule.class).abilityUpgrade();

    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            CatProto.CatRoleAbilityUpgradeRespMsg.Builder respMsg = CatProto.CatRoleAbilityUpgradeRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(Protocol.U_CAT_ABILITY_UPGRADE, respMsg);
        }
    }
}
